package net.sansi.v3correctserver.controller;

import com.dtflys.forest.annotation.Body;
import com.dtflys.forest.annotation.Header;
import com.dtflys.forest.annotation.JSONBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sansi.v3correctserver.dto.R;
import net.sansi.v3correctserver.dto.v3serverapi.V3ServerApiColorDto;
import net.sansi.v3correctserver.service.color.ColorService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;

@Api(tags = "色彩调节接口")
@RestController
@RequestMapping("/color")
@Validated
public class ColorController
{
    @Resource
    private ColorService colorService;

    @ApiOperation("获取Gamma")
    @GetMapping("/gamma")
    public R<V3ServerApiColorDto.factor> gamma(@RequestParam("screenId") @NotBlank String screenId) {
        return R.data(colorService.gamma(screenId));
    }

    @ApiOperation("设置Gamma")
    @PutMapping("/gamma")
    public R<V3ServerApiColorDto.updateResp> gammaUpdate(@RequestParam("screenId") @NotBlank String screenId, @RequestBody V3ServerApiColorDto.factor data) {
        return R.data(colorService.gammaUpdate(screenId, data));
    }

    @ApiOperation("获取Gamma调节方式")
    @GetMapping("/gammaMethod")
    public R<V3ServerApiColorDto.method> gammaMethod(@RequestParam("screenId") @NotBlank String screenId) {
        return R.data(colorService.gammaMethod(screenId));
    }

    @ApiOperation("设置Gamma调节方式")
    @PutMapping("/gammaMethod")
    public R<V3ServerApiColorDto.updateResp> gammaMethodUpdate(@RequestParam("screenId") @NotBlank String screenId, @RequestBody V3ServerApiColorDto.method data) {
        return R.data(colorService.gammaMethodUpdate(screenId, data));
    }

    @ApiOperation("获取内置Gamma表激活标志")
    @GetMapping("/gammaBuiltIn")
    public R<V3ServerApiColorDto.builtIn> gammaBuiltIn(@RequestParam("screenId") @NotBlank String screenId) {
        return R.data(colorService.gammaBuiltIn(screenId));
    }

    @ApiOperation("设置内置Gamma表激活标志")
    @PutMapping("/gammaBuiltIn")
    public R<V3ServerApiColorDto.updateResp> gammaBuiltInUpdate(@RequestParam("screenId") @NotBlank String screenId, @RequestBody V3ServerApiColorDto.builtIn data) {
        return R.data(colorService.gammaBuiltInUpdate(screenId, data));
    }

    @ApiOperation("获取Gamma参数校正模式")
    @GetMapping("/gammaCorrect")
    public R<V3ServerApiColorDto.gammaCorrect> gammaCorrect(@RequestParam("screenId") @NotBlank String screenId) {
        return R.data(colorService.gammaCorrect(screenId));
    }

    @ApiOperation("设置Gamma参数校正模式")
    @PutMapping("/gammaCorrect")
    public R<V3ServerApiColorDto.updateResp> gammaCorrectUpdate(@RequestParam("screenId") @NotBlank String screenId, @RequestBody V3ServerApiColorDto.gammaCorrect data) {
        return R.data(colorService.gammaCorrectUpdate(screenId, data));
    }
}
